package edu.cmu.cs.stage3.alice.authoringtool.viewcontroller;

import edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources;

/**
 * @author Jason Pratt
 */
public class ElementPropertyViewController extends PropertyViewController {
	protected javax.swing.JLabel elementLabel = new javax.swing.JLabel();
	protected edu.cmu.cs.stage3.alice.core.Element root = null;

	public void set( edu.cmu.cs.stage3.alice.core.Property property, boolean allowExpressions, boolean omitPropertyName, final edu.cmu.cs.stage3.alice.authoringtool.util.PopupItemFactory factory ) {
		super.set( property, true, allowExpressions, false, omitPropertyName, factory );
		setPopupEnabled( true );
		refreshGUI();
	}

	/**
	 * used to make Element cascades
	 */
	public void setRoot( edu.cmu.cs.stage3.alice.core.Element root ) {
		this.root = root;
	}

	//Rem @Override
	protected void updatePopupStructure() {
		popupStructure = edu.cmu.cs.stage3.alice.authoringtool.util.PopupMenuUtilities.makePropertyStructure( property, factory, includeDefaults, allowExpressions, includeOther, root );
	}

	//Rem @Override
	protected java.awt.Component getNativeComponent() {
		return elementLabel;
	}

	//Rem @Override
	protected Class getNativeClass() {
		return edu.cmu.cs.stage3.alice.core.Element.class;
	}

	//Rem @Override
	protected void updateNativeComponent() {
		elementLabel.setText( AuthoringToolResources.getNameInContext( (edu.cmu.cs.stage3.alice.core.Element)property.get(), property.getOwner() ) );
	}
}
